package thread;

/**
 * @author tongchen
 * @create 2023-01-04 17:50
 */
public class exer1 {
    public static void main(String[] args) throws InterruptedException {
        //创建新的线程
        Thread thread1=new Thread(()->{
            System.out.println("线程运行");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        System.out.println("线程执行前判断是否存活"+thread1.isAlive()+thread1.getName());
        Thread.sleep(1000);
        thread1.start();
        System.out.println("线程执行中是否存活"+ thread1.isAlive());
        thread1.join();
        System.out.println("线程执行后是否存活"+thread1.isAlive());

    }

}
